<template>
	<view class="list">
		<view class="list-title">其他教练推荐</view>
		<view class="list-content">
			<view class="list-item" v-for="it in list" @click="toClassVideo(it.id,it.user_id)">
				<view class="list-content-img">
					<image :src="it.img" mode="aspectFill"></image>
				</view>
				<view class="list-content-tx">
					{{it.title || ''}}
				</view>
				<view class="list-content-footer">
					<view class="list-content-footer-l">
						<image :src="ossUrl + `/static/icon/5.png`" mode=""></image>
						{{it.nickname || ''}}
					</view>
					<view class="list-content-footer-r">
						播放<text>{{it.play_count || ''}}</text>
					</view>
				</view>
			</view>
			
		</view>
	</view>
</template>

<script>
	import {InformationRelatedRecommendations} from '@/common/http/api.js'
	export default {
		props:['info','courseId'],
		data(){
			return {
				//分页
				params:{
					page: 1,
					course_id: this.courseId
				},
				isList: true,
				list: [],
			}
		},
		created() {
			
			this.init()
		},
		methods:{
			onReachBottomHttp() {
				if(this.isList){
					this.params.page ++
					this.init()
				}
			},
			init(){
				uni.showLoading()
				InformationRelatedRecommendations(this.params).then(res=>{
					uni.hideLoading()
					if(Array.isArray(res.data) && res.data.length > 0) {
						if(this.params.page === 1) {
							this.list = res.data
						} else {
							this.list = this.list.concat(res.data)
						}
					} else {
						this.isList = false
					}
				})
			},
			toClassVideo(id,userId){
				uni.navigateTo({
					url:'/pagesB/teachingCourses/teachingCourses?id=' + id
				})
			},
			toList(){
				uni.navigateTo({
					url:'/pagesA/courseList/courseList?id='+this.info.js.id
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.list {
		width: 690rpx;
		margin: 0 auto;
		padding: 30rpx 0;
		.list-title {
			font-family: Adobe Heiti Std;
			font-weight: normal;
			font-size: 28rpx;
			color: #131313;
			margin-bottom: 26rpx;
			font-weight: bold;
		}
		.list-content {
			display: grid;
			grid-template-columns: repeat(2,1fr);
			grid-gap: 20rpx;
			.list-item {
				flex: 1;
				min-width: 0;
			}
			.list-content-img {
				width: 100%;
				height: 196rpx;
				margin-bottom: 21rpx;
				image {
					width: 100%;
					height: 100%;
					border-radius: 6rpx;
				}
			}
			.list-content-tx {
				height: 60rpx;
				font-family: PingFang SC;
				font-weight: 400;
				font-size: 24rpx;
				color: #131313;
				overflow:hidden;
				text-overflow:ellipsis;
				-webkit-line-clamp:2;
				-webkit-box-orient:vertical;
				margin-bottom: 25rpx;
			}
			.list-content-footer {
				width: 100%;
				display: flex;
				align-items: center;
				justify-content: space-between;
				.list-content-footer-l {
					display: flex;
					align-items: center;
					image {
						width: 36rpx;
						height: 36rpx;
						margin-right: 18rpx;
					}
					font-family: PingFang SC;
					font-weight: 400;
					font-size: 22rpx;
					color: #131313;
				}
				.list-content-footer-r {
					font-family: PingFang SC;
					font-weight: 400;
					font-size: 22rpx;
					color: #131313;
					text {
						color: #12B475;
					}
				}
			}
		}
	}
</style>